package com.example.piece.ui.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.example.piece.entity.Picture
import com.example.piece.ui.fragment.PhotoFragment

/**  视频/图片 Adapter  **/
class PicturePagerAdapter(fragmentManager: FragmentManager, private val pictures: List<Picture>) :
    FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

    override fun getItem(position: Int): Fragment =
        when (pictures[position].isVideo) {
            true -> PhotoFragment.newInstance()
            false -> PhotoFragment.newInstance()
        }

    override fun getCount(): Int = pictures.size

}